﻿using UnityEngine.UI;

namespace JH
{
    /// <summary>
    ///  自定义的toggle事件
    /// </summary>
    public interface IToggleEvent
    {
        /// <summary>
        ///  是否反向
        /// </summary>
        public bool IsReverse { get; set; }
        
        public void OnToggleValueChanged(bool arg0);
    }
    
    public static class ToggleEventHelper
    {
        /// <summary>
        ///  触发自定义的toggle事件
        /// </summary>
        public static void InvokeCustomIsOnEM(this Toggle toggle, bool arg0)
        {
            var toggleEvents = toggle.GetComponents<IToggleEvent>();
            foreach (var each in toggleEvents)
            {
                each.OnToggleValueChanged(arg0);
            }
        }
    }
}